/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.cezary.butler.walili.server;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;

/**
 *
 * @author Czarek
 */
public class URLProtocolHandler implements  URLStreamHandlerFactory{
    
    

    @Override
    public URLStreamHandler createURLStreamHandler(String protocol) {
        if("javascript".equals(protocol))
            return new URLStreamHandler() {

            @Override
            protected URLConnection openConnection(URL u) throws IOException {
                return new URLConnection(u) {

                    @Override
                    public void connect() throws IOException {
                        
                    }
                };
            }
        };
        return null;
    }
    
    public static URLStreamHandlerFactory setUp(){
        final URLProtocolHandler uRLProtocolHandler = new URLProtocolHandler();        
        URL.setURLStreamHandlerFactory(uRLProtocolHandler);
        return uRLProtocolHandler;
    }
    
}
